//
//  PricvacyViewController.swift
//  CJXSwiftStoryboard
//
//  Created by CJX on 2016/10/22.
//  Copyright © 2016年 caijianxi. All rights reserved.
//

import UIKit

class PricvacyViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
    
    
    var myTableView = UITableView(frame: CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT-64), style: .Plain)

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.automaticallyAdjustsScrollViewInsets = false
        self.creatNavVIew()
        self.view.backgroundColor = UIColor.whiteColor()
        self.navigationController?.navigationBar.barTintColor = UIColor(red: 94/255.0, green: 200/255.0, blue: 252/255.0, alpha: 1)
        self.title = "SHIPPING POLICY"
        
        self.creatTableView()
    }
    
    
}


extension PricvacyViewController{
    
    private func creatNavVIew(){
        let leftBtn = UIButton(type: .Custom)
        leftBtn.setImage(UIImage(named: "nav_back"), forState: .Normal)
        leftBtn.frame = CGRectMake(0, 0, 30, 30)
        leftBtn.addTarget(self, action: #selector(leftBtnClick), forControlEvents: .TouchUpInside)
        let item = UIBarButtonItem(customView: leftBtn)
        self.navigationItem.leftBarButtonItem = item
    }
    
    func leftBtnClick(){
        self.dismissViewControllerAnimated(true) {
            
        }
    }
}

extension PricvacyViewController{
    
    private func creatTableView(){
        
        myTableView.delegate = self
        myTableView.dataSource = self
        self.view.addSubview(myTableView)
        
        
    }
    
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }
    
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCellWithIdentifier("cell")
        if cell == nil {
            cell = UITableViewCell(style: .Default, reuseIdentifier: "cell")
        }

        
        let img = UIImageView()
        img.image = UIImage(named: "biaoge")
        cell?.addSubview(img)
        
        if SCREEN_WIDTH == 320 {
            img.frame = CGRectMake(10, 0, SCREEN_WIDTH-20, 2479)
        }else if SCREEN_WIDTH > 320 && SCREEN_WIDTH < 430{
            img.frame = CGRectMake(10, 0, SCREEN_WIDTH-20, 2933)
        }else{
            img.frame = CGRectMake(10, 0, SCREEN_WIDTH-20, 3256)
        }
        
        
        return cell!
    }
    
    func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        if SCREEN_WIDTH == 320 {
            return 2579
        }else if SCREEN_WIDTH > 320 && SCREEN_WIDTH < 430{
            return SCREEN_HEIGHT + 3033
        }else{
            return SCREEN_HEIGHT + 3356
        }
    }
}
